package com.esri.core.renderer;

import com.esri.core.internal.util.d;
import java.io.StringWriter;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonNode;

/* loaded from: classes.dex */
public abstract class BaseRenderer implements Renderer {
    static final String a = "rotationType";
    static final String b = "rotationExpression";
    static final String c = "type";
    private static final long serialVersionUID = -2017454218136048601L;
    protected String rotationExpression;
    protected RotationType rotationType;

    protected abstract String getType();

    public BaseRenderer() {
        this.rotationType = null;
        this.rotationExpression = null;
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public BaseRenderer(JsonNode jsonNode) {
        this.rotationType = null;
        this.rotationExpression = null;
        if (jsonNode == null) {
            return;
        }
        JsonNode jsonNode2 = jsonNode.get(a);
        if (jsonNode2 != null && !jsonNode2.isNull()) {
            this.rotationType = RotationType.fromString(jsonNode2.getTextValue());
        }
        JsonNode jsonNode3 = jsonNode.get(b);
        if (jsonNode3 == null || jsonNode3.isNull()) {
            return;
        }
        this.rotationExpression = jsonNode3.getTextValue();
    }

    public void setRotationType(RotationType rotationType) {
        this.rotationType = rotationType;
    }

    public RotationType getRotationType() {
        return this.rotationType;
    }

    public void setRotationExpression(String str) {
        this.rotationExpression = str;
    }

    public String getRotationExpression() {
        return this.rotationExpression;
    }

    @Override // com.esri.core.renderer.Renderer
    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a2 = d.a(stringWriter);
        a2.writeStartObject();
        toJson(a2);
        a2.writeEndObject();
        a2.close();
        return stringWriter.toString();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void toJson(JsonGenerator jsonGenerator) throws Exception {
        jsonGenerator.writeStringField(c, getType());
        RotationType rotationType = this.rotationType;
        if (rotationType != null) {
            jsonGenerator.writeStringField(a, rotationType.getValue());
        }
        d.a(jsonGenerator, b, this.rotationExpression);
    }
}
